import React from 'react';
import "./index.css";

export default class extends React.Component{
    constructor(props){
        super();
        this.state={
            leftTitle:props.leftTitle,
            rightTitle:props.rightTitle,
            click:props.click,
            selectSecond:props.selectSecond
        }
    }
    Click(){
        console.log("click")
        let state=this.state.selectSecond;
        this.setState({
            selectSecond:!state
        },()=>{
            if(this.state.click!==undefined){
                this.state.click();
            }
        })
    }
    render()
    {
        
        return(
            <div className="TiggleBtn NoSelect" onClick={e=>this.Click(e)}>
                <span className={!this.state.selectSecond?
                        "TiggleBtn_Item TiggleBtn_Select":
                        "TiggleBtn_Item"}
                        >{this.state.leftTitle}</span>
                <span className={this.state.selectSecond?
                    "TiggleBtn_Item TiggleBtn_Select":
                    "TiggleBtn_Item"}
                    >{this.state.rightTitle}</span>
            </div>
        );
    }
}